<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "{{%form}}".
 *
 * @property integer $id
 * @property string $title
 * @property string $description
 * @property integer $cover
 * @property string $content
 * @property integer $created_at
 * @property integer $updated_at
 * @property integer $status
 * @property integer $start_time
 * @property integer $end_time
 * @property string $mail
 * @property string $tel
 * @property integer $num
 *
 * @property FormInput[] $formInputs
 */
class Form extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%form}}';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['title', 'description', 'content', 'created_at', 'updated_at', 'start_time', 'end_time', 'mail'], 'required'],
            [['cover', 'created_at', 'updated_at', 'status', 'start_time', 'end_time', 'num'], 'integer'],
            [['content'], 'string'],
            [['title'], 'string', 'max' => 80],
            [['description'], 'string', 'max' => 200],
            [['mail'], 'string', 'max' => 128],
            [['tel'], 'string', 'max' => 20],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'title' => 'Title',
            'description' => 'Description',
            'cover' => 'Cover',
            'content' => 'Content',
            'created_at' => 'Created At',
            'updated_at' => 'Updated At',
            'status' => 'Status',
            'start_time' => 'Start Time',
            'end_time' => 'End Time',
            'mail' => 'Mail',
            'tel' => 'Tel',
            'num' => 'Num',
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getFormInputs()
    {
        return $this->hasMany(FormInput::className(), ['form_id' => 'id']);
    }
}
